@extends('layout.master')
@section('title', '商品详情')
@section('content')
    <script src="{{URL::asset('js/base64.js')}}"></script>
{{--    <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/aes.min.js"></script>--}}
    <body class="easyui-layout" id="app" style="background: white">
    <form id="form1">
        {{csrf_field()}}
        <h1>会员信息绑定</h1>
        <p>openid:<input type="text" name="open_id" class="open_id" value=""></p>
        <p>电话:<input type="text" name="telephone" class="telephone" value=""></p>
        <p><button class="btn1">会员信息绑定</button></p>
    </form>
    <form id="form2">
        {{csrf_field()}}
        <h1>会员信息查询</h1>
        <p>openid:<input type="text" name="open_id" class="open_id" value=""></p>
        <p><button class="btn2">会员信息查询</button></p>
    </form>
    <form id="form3">
        {{csrf_field()}}
        <h1>可用积分查询</h1>
        <p>openid:<input type="text" name="open_id" class="open_id" value=""></p>
        <p><button class="btn3">可用积分查询</button></p>
    </form>
    <form id="form4">
        {{csrf_field()}}
        <h1>积分明细查询</h1>
        <p>openid:<input type="text" name="open_id" class="open_id" value=""></p>
        <p><button class="btn4">积分明细查询</button></p>
    </form>
    <form id="form5">
        {{csrf_field()}}
        <h1>积分兑换</h1>
        <p>openid:<input type="text" name="open_id" class="open_id" value=""></p>
        <p><button class="btn5">积分兑换</button></p>
    </form>

    <form id="form6">
        {{csrf_field()}}
        <h1>积分作废</h1>
        <p>openid:<input type="text" name="open_id" class="open_id" value=""></p>
        <p><button class="btn6">积分作废</button></p>
    </form>

    <script>
        var aseKey = "958802882010913257074332"     //秘钥必须为：8/16/32位
        var message = "80018000142";
        //会员信息绑定
        $(".btn1").on("click",function (res) {
            let data = {"open_id":'23',"telephone":'18862883588'}
            $.ajax({
                url:"http://58.211.43.142:8080/resweb/outInterface.out?method=bindMember",
                method:"post",
                data:data,
                success:function (res) {
                    console.log(res.data);
                }
            })
            return false;
        })
        //会员查询接口
        $(".btn2").on("click",function (res) {
            let data = {"open_id":'o512dwh27hXWjFWMoLbclQMchR2A'}
            $.ajax({
                url:"http://58.211.43.142:8080/resweb/outInterface.out?method=queryMemberByOpenId",
                method:"post",
                data:data,
                success:function (res) {
                    $.post("http://10.36.8.15:8080/ssm/account/getDecryptString", {"param":res.data}, function (data) {
                        console.log(data);
                    });
                }
            })
            return false;
        })
        //可用积分查询
        $(".btn3").on("click",function (res) {
            let data = {"open_id":'o512dwh27hXWjFWMoLbclQMchR2A'}
            $.ajax({
                url:"http://58.211.43.142:8080/resweb/outInterface.out?method=queryRemainedPoint",
                method:"post",
                data:data,
                success:function (res) {
                    console.log(res.data);
                }
            })
            return false;
        })
        //积分明细查询
        $(".btn4").on("click",function (res) {
            let data = {"open_id":'123456',"begin_date":"2019-11-1","end_date":"2019-12-18"}
            $.ajax({
                url:"http://58.211.43.142:8080/resweb/outInterface.out?method=queryPointDetail",
                method:"post",
                data:data,
                dataType:"json",
                success:function (res) {
                    console.log(res.data);
                }
            })
            return false;
        })
        //积分兑换
        $(".btn5").on("click",function (res) {
            let id = '1'+uuid(30,10);
            let data = {"open_id":'123456',"change":"11","ID":id,'change_reason':'积分兑换','change_business':'天天鲜美食汇'};
                $.ajax({
                url:"http://58.211.43.142:8080/resweb/outInterface.out?method=pointExchange",
                method:"post",
                data:data,
                success:function (res) {
                    console.log(res.data);
                }
            })
            return false;
        })
        $(".btn6").on("click",function (res) {
            let id = '1'+uuid(30,10);
            let data = {"open_id":'123456',"change":"20","ID":id,'change_reason':'积分兑换','change_business':'天天鲜美食汇999'};
            $.ajax({
                url:"http://58.211.43.142:8080/resweb/outInterface.out?method=pointExchangeCancel",
                method:"post",
                data:data,
                success:function (res) {
                    console.log(res.data);
                }
            })
            return false;
        })

        function uuid(len, radix) {
            var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
            var uuid = [], i;
            radix = radix || chars.length;

            if (len) {
                // Compact form
                for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
            } else {
                // rfc4122, version 4 form
                var r;

                // rfc4122 requires these characters
                uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
                uuid[14] = '4';

                // Fill in random data.  At i==19 set the high bits of clock sequence as
                // per rfc4122, sec. 4.1.5
                for (i = 0; i < 36; i++) {
                    if (!uuid[i]) {
                        r = 0 | Math.random()*16;
                        uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
                    }
                }
            }
            return uuid.join('');
        }

    </script>
    </body>
@endsection
